package com.xc.h05.service.lishenao.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xc.h05.entity.Articletype;
import com.xc.h05.mapper.ArticletypeMapper;
import com.xc.h05.service.lishenao.ArticletypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ArticletypeServiceImpl implements ArticletypeService {
    @Autowired
    private ArticletypeMapper articletypeMapper;
    @Override
    public List<Articletype> selectAll() {
        return articletypeMapper.selectAll();
    }

    @Override
    public PageInfo<Articletype> selectAllWithArticle(Articletype articletype, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Articletype> articletypes = articletypeMapper.selectAllArticletypeByname(articletype);
        PageInfo<Articletype> pageInfo = new PageInfo<>(articletypes);
        return pageInfo;

    }

    @Override
    public int add(Articletype articletype) {
        return  articletypeMapper.insert(articletype);
    }

    @Override
    public int deleteById(Long id) {
        return  articletypeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(Articletype articletype) {
        return  articletypeMapper.updateByPrimaryKey(articletype);
    }

    @Override
    public Articletype selectByPrimaryKey(Long id) {
        return articletypeMapper.selectByPrimaryKey(id);
    }
}
